package com.yidu.controller;

import com.yidu.entity.AmUserRole;
import com.yidu.service.AmUserRoleService;
import com.yidu.utils.BaseMessage;
import org.springframework.web.bind.annotation.*;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.Map;

/**
 * 用户关联角色(AmUserRole)表控制层
 *
 * @author wanghong
 * @since 2021-08-02 11:48:29
 */
@RestController
@RequestMapping("amUserRole")
public class AmUserRoleController {
    /**
     * 服务对象
     */
    @Autowired
    private AmUserRoleService amUserRoleService;

    /**
     * 通过主键查询单条数据
     *
     * @param id 主键
     * @return 单条数据
     */
    @GetMapping("selectOne")
    public AmUserRole selectOne(Integer id) {
        return this.amUserRoleService.queryById(id);
    }

    /**
     * 查询用户的所有角色
     *
     * @return
     */
    @RequestMapping("findByUserId")
    @ResponseBody
    public Map<String,Object> findByUserId(Integer userId){
        AmUserRole amUserRole = amUserRoleService.findByUserId(userId);

        return BaseMessage.judge("1","操作成功",amUserRole);
    }
    
}
